package com.epower.bo.epower.commons;

import java.util.Map;

public class Result implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer resultCode;
	private String message;
	private Map<String, ? extends Object> result;
	public final static int RESULTCODE_NORMAL = 1; // 正常
	public final static int RESULTCODE_REQUEST_FAILURE = -1; // 请求失败
	public final static int RESULTCODE_TOKENVALIDATE_FAILURE = -2; // 签名验证失败
	public final static int RESULTCODE_PARAMETER_ILLEGAL = -3; // 参数非法

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Integer getResultCode() {
		return resultCode;
	}

	public void setResultCode(Integer resultCode) {
		this.resultCode = resultCode;
	}

	public boolean isOK() {
		if (this.resultCode.equals(RESULTCODE_NORMAL)) {
			return true;
		} else {
			return false;
		}
	}

	public Map<String, ? extends Object> getResult() {
		return result;
	}

	public void setResult(Map<String, ? extends Object> result) {
		this.result = result;
	}

	public static Result succResult() {
		Result r = new Result();
		r.setResultCode(RESULTCODE_NORMAL);
		return r;
	}

	public static Result errorResult(int resultCode, String message) {
		Result r = new Result();
		r.setResultCode(resultCode);
		r.setMessage(message);
		return r;
	}

	public static Result commonResult(String message) {
		Result r = new Result();
		r.setResultCode(RESULTCODE_NORMAL);
		r.setMessage(message);
		return r;
	}

}
